SQL Editor - Build Query - Show Unions
The UNION statement allows you to combine multiple queries together to create a single result set. All queries in the union SELECT statements must have an equal number of expressions. In addition, these expressions (column names, literals, dates, results from functions, etc.) must be of compatible data types.
Argos does not check to make sure you have added the correct number of columns or that the data types of the columns added are the same. So be sure to check this. Note that when adding columns in the UNION window, there is no spot for the "AS" or "Description" fields. These will default to the values set in the Main query.
To create a union query:
- Click on the Show Unions button.
- Select the type of Union (from the Union Toolbar) you would like to add to your main query.
- Create your query.
You can add multiple unions to your query list. To edit the query for a particular union or the main query, select it from the query list.
Union Toolbar
Button | Description |
---|---|
A standard union combines the results of the two queries into one result set excluding any duplicate records. | |
A UNION ALL union combines the results of the two queries into one result set and does not remove any duplicate records. | |
An INTERSECT union returns only those records that exist in both. | |
A MINUS union returns all records from the first query except for those records which also exist in the second query. | |
Delete the union query from your list of queries. | |
Copy the union query to the clipboard. | |
Paste the query from the clipboard into the current union, overwriting it. | |
Edit the union properties. Set the name and the type of union. | |
View the SQL generated by all of the union queries together. |
Sample SQL
Clicking the View SQL button shows you the SQL statement that contains the full query, including any unions. In this example, the main query is unioned with two additional queries that select the departments from three different tables:
- If you need additional help creating DataBlocks, refer to the Getting Started with DataBlocks page.
- To read a step-by-step tutorial on how to create Unions, refer to Example 13 in the Argos DataBlock Designers Guide.